package com.ljm.shiro.conf;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;

/**
 * 版权：    Copyright by ljm
 * 描述：
 * 修改人：  HuamingChen
 * 修改时间：2018/12/12
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */
@ConfigurationProperties(prefix = "shiro")
public class ShiroProperties {
    /**
     * Encryption mode
     */
    private CredentialsMatcher credentialsMatcher = new CredentialsMatcher();

    /**
     * Anonymous path
     */
    private List<String> anonUrl;
    /**
     * 外接系统接口配置
     */
    private List<String> outJoinSysUrl;
    /**
     * Login path
     */
    private String loginUrl = "/login";
    /**
     * Logon Success Path
     */
    private String successUrl = "/index";
    /**
     * No permission path
     */
    private String unauthorizedUrl = "/unauthorized";
    /**
     * cookie
     */
    private Cookie cookie = new Cookie();
    /**
     * session
     */
    private Session session = new Session();

    public static class CredentialsMatcher {
        private String matcherName = "MD5";
        private int iterations = 5;

        public String getMatcherName() {
            return matcherName;
        }

        public void setMatcherName(String matcherName) {
            this.matcherName = matcherName;
        }

        public int getIterations() {
            return iterations;
        }

        public void setIterations(int iterations) {
            this.iterations = iterations;
        }
    }

    public static class Cookie {
        private String domain;
        private Integer maxAge;
        private String name = "jsessionid";
        private String path;
        private boolean httpOnly = true;

        public String getDomain() {
            return domain;
        }

        public void setDomain(String domain) {
            this.domain = domain;
        }

        public Integer getMaxAge() {
            return maxAge;
        }

        public void setMaxAge(Integer maxAge) {
            this.maxAge = maxAge;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPath() {
            return path;
        }

        public void setPath(String path) {
            this.path = path;
        }

        public boolean isHttpOnly() {
            return httpOnly;
        }

        public void setHttpOnly(boolean httpOnly) {
            this.httpOnly = httpOnly;
        }
    }

    public static class Session {
        private long sessionExpireTime = 7200000;
        private long authExpireTime = 600000;

        public long getSessionExpireTime() {
            return sessionExpireTime;
        }

        public void setSessionExpireTime(long sessionExpireTime) {
            this.sessionExpireTime = sessionExpireTime;
        }

        public long getAuthExpireTime() {
            return authExpireTime;
        }

        public void setAuthExpireTime(long authExpireTime) {
            this.authExpireTime = authExpireTime;
        }
    }

    public CredentialsMatcher getCredentialsMatcher() {
        return credentialsMatcher;
    }

    public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) {
        this.credentialsMatcher = credentialsMatcher;
    }

    public List<String> getAnonUrl() {
        return anonUrl;
    }

    public void setAnonUrl(List<String> anonUrl) {
        this.anonUrl = anonUrl;
    }

    public String getLoginUrl() {
        return loginUrl;
    }

    public void setLoginUrl(String loginUrl) {
        this.loginUrl = loginUrl;
    }

    public String getSuccessUrl() {
        return successUrl;
    }

    public void setSuccessUrl(String successUrl) {
        this.successUrl = successUrl;
    }

    public String getUnauthorizedUrl() {
        return unauthorizedUrl;
    }

    public void setUnauthorizedUrl(String unauthorizedUrl) {
        this.unauthorizedUrl = unauthorizedUrl;
    }

    public Cookie getCookie() {
        return cookie;
    }

    public void setCookie(Cookie cookie) {
        this.cookie = cookie;
    }

    public Session getSession() {
        return session;
    }

    public void setSession(Session session) {
        this.session = session;
    }

    public List<String> getOutJoinSysUrl() {
        return outJoinSysUrl;
    }

    public void setOutJoinSysUrl(List<String> outJoinSysUrl) {
        this.outJoinSysUrl = outJoinSysUrl;
    }
}
